package wwl.lsf.autuwired2kind;

import java.util.Map;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class TwoKindService implements ApplicationContextAware {

  private ApplicationContext applicationContext;

//  public void setTwoKindDao(TwoKindDao twoKindDao) {
//    this.twoKindDao = twoKindDao;
//  }
//
  @Autowired
  private TwoKindDao twoKindDao12;

//  public void setTwoKindDaoMap(
//      Map<String, TwoKindDao> twoKindDaoMap) {
//    this.twoKindDaoMap = twoKindDaoMap;
//  }

  //  @Autowired
  private Map<String, TwoKindDao> twoKindDaoMap;

  public void query(String daoName) {
    System.out.println(applicationContext.getBean(daoName));
    this.twoKindDaoMap.get(daoName).query();
  }

  @Override
  public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext;
  }
}
